<?php

namespace common\models;

use Yii;
use common\models\HouseModel;
use common\models\AdverttypeModel;
/**
 * This is the model class for table "{{%country}}".
 *
 * @property string $code
 * @property string $name
 * @property integer $population
 */
class AdvertModel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%advert}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['atype','isshow','houseid'], 'integer'],           
            [['advicon'], 'string', 'max' => 150,'min'=>2],
        ];
    }
	
	public function getHouse(){
		return $this->hasOne(HouseModel::className(), ['id' => 'houseid']);
	}
	
	public function getAdverttype(){
		return $this->hasOne(AdverttypeModel::className(), ['tid' => 'atype']);
	}

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'atype' => '广告的类型',
            'advicon' => '图标',
            'isshow' => '是否显示',
            'houseid' => '房子编号'
        ];
    }
}
